package com.api.shopapi.service.impl;


import com.api.shopapi.entity.OrderBusinessAppraise;
import com.api.shopapi.entity.dto.OrderBusinessAppraiseDTO;
import com.api.shopapi.mapper.OrderBusinessAppraiseMapper;
import com.api.shopapi.service.OrderBusinessAppraiseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("OrderBusinessAppraiseServiceImplOne")
public class OrderBusinessAppraiseServiceImpl implements OrderBusinessAppraiseService {

    @Autowired
    private OrderBusinessAppraiseMapper orderBusinessAppraiseMapper;

    @Override
    public int insert(OrderBusinessAppraise orderBusinessAppraise) {
        return orderBusinessAppraiseMapper.insert(orderBusinessAppraise);
    }

    @Override
    public int delete(String orderBusinessAppraiseCode) {
        return orderBusinessAppraiseMapper.delete(orderBusinessAppraiseCode);
    }

    @Override
    public int update(OrderBusinessAppraise orderBusinessAppraise) {
        return orderBusinessAppraiseMapper.update(orderBusinessAppraise);
    }

    @Override
    public List<OrderBusinessAppraise> getList() {
        return orderBusinessAppraiseMapper.getList();
    }

    @Override
    public OrderBusinessAppraise getByOrderBusinessAppraiseCode(String orderBusinessAppraiseCode) {
        return orderBusinessAppraiseMapper.getByOrderBusinessAppraiseCode(orderBusinessAppraiseCode);
    }

    @Override
    public OrderBusinessAppraise getByOrderBusinessCode(String orderBusinessCode){
        return orderBusinessAppraiseMapper.getByOrderBusinessCode(orderBusinessCode);
    }




    //商家代表下的订单的评论
    @Override
    public List<OrderBusinessAppraiseDTO> getListByBusinessTopCodeBusinessCode(String businessTopCode,
                                                                               String businessCode){
        return orderBusinessAppraiseMapper.getListByBusinessTopCodeBusinessCode(businessTopCode,businessCode);
    }
    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getPageInfoByBusinessTopCodeBusinessCode(int pageNum,
                                                                                                int pageSize,
                                                                                                String businessTopCode,
                                                                                                String businessCode){
        PageHelper.startPage(pageNum, pageSize);
        List<OrderBusinessAppraiseDTO> list = orderBusinessAppraiseMapper.getListByBusinessTopCodeBusinessCode(businessTopCode,businessCode);
        PageInfo<OrderBusinessAppraiseDTO> pageInfo = new PageInfo<OrderBusinessAppraiseDTO>(list);
        return pageInfo;
    }



    //政府下的订单的评论
    @Override
    public List<OrderBusinessAppraiseDTO> getListByGovernmentCodeBusinessCode(String governmentCode,
                                                                              String businessCode){
        return orderBusinessAppraiseMapper.getListByGovernmentCodeBusinessCode(governmentCode,businessCode);
    }
    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getPageInfoByGovernmentCodeBusinessCode(int pageNum,
                                                                               int pageSize,
                                                                               String governmentCode,
                                                                               String businessCode){
        PageHelper.startPage(pageNum, pageSize);
        List<OrderBusinessAppraiseDTO> list = orderBusinessAppraiseMapper.getListByGovernmentCodeBusinessCode(governmentCode,businessCode);
        PageInfo<OrderBusinessAppraiseDTO> pageInfo = new PageInfo<OrderBusinessAppraiseDTO>(list);
        return pageInfo;
    }







    //所有评价（居委会，街道）
    @Override
    public List<OrderBusinessAppraiseDTO> getListByZoneCode(String zoneCode){
        return orderBusinessAppraiseMapper.getListByZoneCode(zoneCode);
    }
    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getPageInfoByZoneCode(int pageNum,
                                                     int pageSize,
                                                     String zoneCode){
        PageHelper.startPage(pageNum, pageSize);
        List<OrderBusinessAppraiseDTO> list = orderBusinessAppraiseMapper.getListByZoneCode(zoneCode);
        PageInfo<OrderBusinessAppraiseDTO> pageInfo = new PageInfo<OrderBusinessAppraiseDTO>(list);
        return pageInfo;
    }



    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getBusinessPageList(int pageIndex, int pageSize, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOList=orderBusinessAppraiseMapper.getBusinessPageList(businessCode);
        return new PageInfo<>(orderBusinessAppraiseDTOList);
    }

    //服务人员查看订单评价
    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getBusinessPageListServe(int pageIndex, int pageSize, String businessCode, String zoneCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOList =orderBusinessAppraiseMapper.getBusinessPageListServe(businessCode, zoneCode);
        return new PageInfo<>(orderBusinessAppraiseDTOList);
    }

    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getAppraisePageByServer(int pageIndex, int pageSize, String userCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOS = orderBusinessAppraiseMapper.getAppraisePageByServer(userCode);
        return new PageInfo<>(orderBusinessAppraiseDTOS);
    }

    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getGovernmentPageList(int pageIndex, int pageSize, String government) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOList=orderBusinessAppraiseMapper.getGovernmentPageList(government);
        return new PageInfo<>(orderBusinessAppraiseDTOList);
    }

    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getJWHAndJDPageList(int pageIndex, int pageSize,String zoneCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOList=orderBusinessAppraiseMapper.getJWHAndJDPageList(zoneCode);
        return new PageInfo<>(orderBusinessAppraiseDTOList);
    }

    @Override
    public PageInfo<OrderBusinessAppraiseDTO> getPageToGovPlatform(int pageIndex, int pageSize, String governmentCode, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<OrderBusinessAppraiseDTO> orderBusinessAppraiseDTOList=orderBusinessAppraiseMapper.getPageToGovPlatform(governmentCode,businessCode);
        return new PageInfo<>(orderBusinessAppraiseDTOList);
    }


}
